function runTest(element, code) {
	document.getElementById("all-status").style.background = 'grey';
	$('.status').css('background-color', 'grey');
	var status = true;
	$('.details').html("");
	$.ajax({
		type: "GET",
		url: "/test?code=" + code,
		success: function(data) {
			response = data;
			for (i=0 ; i<response.length ; i++) {
				name = response[i].name;
				success = response[i].success;
				methods = response[i].methods;
				if (success == true) {
					document.getElementById(name + "-status").style.background = 'green';
					status = status && true;
				} else {
					document.getElementById(name + "-status").style.background = 'red';
					status = status && false;
					
					//Add the stack trace
					append = "";
					for (a=0 ; a<methods.length ; a++) {
						append += '<h3 class="l2">' + methods[a].name + '</h3>';
						tests = methods[a].tests;
						for (b=0 ; b<tests.length ; b++) {
							append += '<p class="left l3">' + tests[b].name + '</p>';
							success = tests[b].success;
							if (success == true) {
								append += '<div class="right status" style="background-color: green;"></div>';
							} else {
								append += '<div class="right status" style="background-color: red;"></div>';
							}
							append += '<div class="clear"></div>';
							append += '<p class="l4">' + tests[b].stackTrace + '</p>';
						}
					}
					$('#' + name).children('.details').html(append);
				}
			}
			statusElements = $('.status');
			statusElements.each( function(i, obj) {
				colour = $(this).css('background-color');
				if (colour == "rgb(0, 128, 0)") {
					status = status && true;
				} else if (colour == "rgb(255, 0, 0)") {
					status = status && false;
				} else {
					status = null;
				}
			});
			if (status == true) {
				document.getElementById("all-status").style.background = 'green';
			} else if (status == false) {
				document.getElementById("all-status").style.background = 'red';
			}
		}
	});
}

$("button").click(function () {
	$("p").toggle("slow");
});